package vikaa.adapter;

import java.util.ArrayList;

import vikaa.bean.WeiboFriend;
import vikaa.wowo.R;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;


public class WowoCreate3Adapter extends BaseAdapter{
	private Context context;
	private LayoutInflater inflater;
	private final ArrayList<WeiboFriend>  wbList; 
	private ListView listView;
    
    public WowoCreate3Adapter(Context context, ArrayList<WeiboFriend> wbList,ListView listView) {
		super();
		this.context = context;
		this.inflater = LayoutInflater.from(context);
		this.wbList = wbList;
		this.listView = listView;
	}

    public int getCount() {
        return wbList.size();
    }

    public Object getItem(int position) {
        return wbList.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = inflater.inflate(R.layout.wowo_create3_item, null);
        Holder wh = new Holder();
        wh.name = (TextView) convertView.findViewById(R.id.nameTv);
        wh.phone = (TextView) convertView.findViewById(R.id.phoneTv);
        wh.arrow = (ImageView)convertView.findViewById(R.id.arrawImg);
        WeiboFriend wb = wbList.get(position);
        if(wb!=null){
        	Bundle b=new Bundle();
            b.putString("id", wb.getId());
            b.putString("name", wb.getName());
            b.putString("phone", wb.getPhone());
            convertView.setTag(b);
            wh.name.setText(wb.getName());
            
            if(wb.getPhone().indexOf("1") != -1){
            	wh.phone.setText(wb.getPhone());
            	wh.arrow.setVisibility(View.VISIBLE);
            }
        }
        return convertView;
	}
	class Holder {
		public TextView name = null;
		public TextView phone =null;
		public ImageView arrow = null;
	}

}

